package org.eenie.learn.seedquartz.utils;

import com.alibaba.fastjson.JSON;
import org.eenie.learn.seedquartz.config.Config;
import org.eenie.learn.seedquartz.model.OrderModel;
import org.eenie.learn.seedquartz.model.RemoteSeat;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class OrderInfo {

    List<OrderModel> mOrderModels = new ArrayList<>();


    RemoteSeat mSeatModel;


    public OrderInfo() {
        mSeatModel = new RemoteSeat();

        if (Config.type == 0) {
            mOrderModels.add(new OrderModel("唐海斌", "450902199211011735", mSeatModel));
            mOrderModels.add(new OrderModel("李玲玲", "330302199505076526", mSeatModel));
        } else {
            mOrderModels.add(new OrderModel("潘芝琴", "352124196812032928", mSeatModel));
            mOrderModels.add(new OrderModel("李严利", "330302199809258839", mSeatModel));
        }
        System.out.println(JSON.toJSONString(mOrderModels));
    }


    public void refresh() {
        mSeatModel = new RemoteSeat();
        mOrderModels.clear();
        if (Config.type == 0) {
            mOrderModels.add(new OrderModel("唐海斌", "450902199211011735", mSeatModel));
            mOrderModels.add(new OrderModel("李玲玲", "330302199505076526", mSeatModel));
        } else {
            mOrderModels.add(new OrderModel("潘芝琴", "352124196812032928", mSeatModel));
            mOrderModels.add(new OrderModel("李严利", "330302199809258839", mSeatModel));
        }
        System.out.println(JSON.toJSONString(mOrderModels));
    }


    public List<OrderModel> getOrderModels() {
        return mOrderModels;
    }

    public void setOrderModels(List<OrderModel> orderModels) {
        mOrderModels = orderModels;
    }

    public RemoteSeat getSeatModel() {
        return mSeatModel;
    }

    public void setSeatModel(RemoteSeat seatModel) {
        mSeatModel = seatModel;
        for (OrderModel orderModel : mOrderModels) {
            orderModel.setSeat(seatModel);
        }
    }
}
